<?php $form = $this->beginWidget('CActiveForm'); ?>
<div class="well horizontal">
    <span>Chọn tháng</span> <?php echo CHtml::textField('date', null, array()); ?>
    <?php echo CHtml::submitButton('Xem', array('class' => 'btn btn-primary', 'name' => 'view')); ?>
</div>
<?php $this->endWidget(); ?>
<table class="table table-striped table-bordered table-condensed">
    <thead>
        <tr>
            <th>#</th>
            <th>Tên nhân viên</th>
            <?php foreach ($workshifts as $ws): ?>
                <th class="cell-center" colspan="3">
                    <?php echo $ws->title; ?><br/>
                </th>
            <?php endforeach; ?>
            <th>Tiền lương</th>
        </tr>
        <tr>
            <th>&nbsp;</th>
            <th>&nbsp</th>
            <?php foreach ($workshifts as $ws): ?>
                <th class="cell-center"><?php echo UserModule::t('Present Short', array(), 'attendance'); ?></th>
                <th class="cell-center"><?php echo UserModule::t('Paid Leave Short', array(), 'attendance'); ?></th>
                <th class="cell-center"><?php echo UserModule::t('Un Paid Leave Short', array(), 'attendance'); ?></th>
            <?php endforeach; ?>
            <th>&nbsp;</th>  
        </tr>
    </thead>
    <tbody>
        <?php foreach ($results as $row): ?>
            <tr>
                <td><?php echo $row['id'] ?></td>
                <td>
                    <?php
                    echo CHtml::link($row['name'], array('attendance/report-detail',
                        'month' => date('m', strtotime($date)),
                        'year' => date('Y', strtotime($date)),
                        'user_id' => $row['id']
                    ));
                    ?>
                </td>
    <?php foreach ($workshifts as $ws): ?>
                    <td><?php echo $row['summary']->present[$ws->workshift_id] ?></td>
                    <td><?php echo $row['summary']->paid[$ws->workshift_id] ?></td>
                    <td><?php echo $row['summary']->unpaid[$ws->workshift_id] ?></td>
            <?php endforeach; ?>
                <td style="text-align: right"><?php echo Yii::app()->numberFormatter->formatCurrency($row['summary']->total_paid, "VND"); ?></td>
            </tr>
<?php endforeach; ?>
    </tbody>
</table>
<script>
    $(function() {
        $("#date").datepicker({
            changeMonth: true,
            changeYear: true,
            showButtonPanel: true
        });
        $("#date").datepicker('setDate', '<?php echo $date; ?>');
    });
</script>